/* Copyright (c) 2004-2022 peigen.info. All rights reserved. */

package info.peigen.hotpot.common.core.domain;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
import info.peigen.hotpot.common.core.annotation.Comment;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

/**
 * <b>(Picture)</b>
 * 图片类
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/7/27
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class Image {
    @Comment(value = "长")
    String length;
    @Comment(value = "宽")
    String width;
    @Comment(value = "高")
    String size;
    @Comment(value = "旋转角度-0为不旋转")
    @Builder.Default
    String angle = "0";
    @Comment(value = "名字")
    String name;
    @Comment(value = "路径,可以是本地或url")
    String path;

    public void check() {
        Assert.isTrue(StrUtil.isAllNotEmpty(name, path));
        Validator.validateUrl(path, "[path]必须是URL");
    }
}